{% load i18n %}
{% load static %}

<!DOCTYPE html>
<html lang="{% get_current_language as LANGUAGE_CODE %}">

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{% block title %}Community{% endblock %}</title>
    <!-- 浏览器标签图标 -->
    <link rel="icon" type="image/png" href="{% static 'img/favicon.png' %}">
    <!-- 静态文件 -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="{% static 'css/bootcamp.css' %}" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    {% block head %}
    {% endblock head %}
  </head>

  <body>
    {% block body %}
      <!-- 导航栏 START -->
      <header>
        <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
          <div class="container-fluid">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menu">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <a class="navbar-brand" href="{% url 'home' %}">Community</a>
            </div>
            <div class="collapse navbar-collapse" id="menu">
              <ul class="nav navbar-nav">
                <li><a href="{% url 'questions:questions_list' %}">{% trans 'Q&A' %}</a></li>
              </ul>
              {% if not hide_search %}
                <!-- 导航栏左侧搜索表单 START -->
                <form class="navbar-form navbar-left" role="search" action="{% url 'search:search' %}">
                  <div class="input-group" style="width:210px">
                    <input type="text" class="form-control" name="q" placeholder="{% trans 'Search' %}">
                    <span class="input-group-btn">
                      <button type="submit" class="btn btn-default">
                        <span class="glyphicon glyphicon-search"></span>
                      </button>
                    </span>
                  </div>
                </form>
                <!-- 导航栏左侧搜索表单 END -->
              {% endif %}
              <!-- 导航栏右侧按钮 START -->
              <ul class="nav navbar-nav navbar-right">
                {% if not user.is_anonymous %}
                  <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                      {{ user.get_username }}
                      <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                      <li><a href="{% url 'user_profile:profile' user.id %}">{% trans 'Profile' %}</a></li>
                      <li class="divider"></li>
                      <li><a href="{% url 'authentication:logout' %}">{% trans 'Log out' %}</a></li>
                    </ul>
                  </li>
                {% else %}
                  <li><a href="{% url 'authentication:signup' %}">{% trans 'Sign up' %}</a></li>
                  <li><a href="{% url 'authentication:login' %}">{% trans 'Log in' %}</a></li>
                {% endif %}
              </ul>
              <!-- 导航栏右侧按钮 END -->
            </div>
          </div>
        </nav>
      </header>
      <!-- 导航栏 END -->
      <main>
        <div class='container'>
          <!-- 页面顶部展示消息 START -->
          {% if messages %}
            {% for m in messages %}
              <div class="alert alert-{{ m.tags }} alert-dismissable">
                <button type="button" class="close" data-dismiss="alert"
                  aria-hidden="true">&times;</button>
                {{ m }}
              </div>
            {% endfor %}
          {% endif %}
          <!-- 页面顶部展示消息 END -->
          {% block main %}
          {% endblock main %}
        </div>
      </main>
    {% endblock body %}
    <script src="{% static 'js/ga.js' %}"></script>
  </body>
</html>
